Option Strict On
Option Explicit On 

Public Class URelation
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents nudSideMargin As System.Windows.Forms.NumericUpDown
    Friend WithEvents lblSideMargin As System.Windows.Forms.Label
    Friend WithEvents chkVisible As System.Windows.Forms.CheckBox
    Friend WithEvents lblName As System.Windows.Forms.Label
    Friend WithEvents txtName As System.Windows.Forms.TextBox
    Friend WithEvents ErrorProvider1 As System.Windows.Forms.ErrorProvider
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(URelation))
        Me.lblName = New System.Windows.Forms.Label
        Me.txtName = New System.Windows.Forms.TextBox
        Me.nudSideMargin = New System.Windows.Forms.NumericUpDown
        Me.lblSideMargin = New System.Windows.Forms.Label
        Me.chkVisible = New System.Windows.Forms.CheckBox
        Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider
        CType(Me.nudSideMargin, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'lblName
        '
        Me.lblName.AccessibleDescription = resources.GetString("lblName.AccessibleDescription")
        Me.lblName.AccessibleName = resources.GetString("lblName.AccessibleName")
        Me.lblName.Anchor = CType(resources.GetObject("lblName.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.lblName.AutoSize = CType(resources.GetObject("lblName.AutoSize"), Boolean)
        Me.lblName.Dock = CType(resources.GetObject("lblName.Dock"), System.Windows.Forms.DockStyle)
        Me.lblName.Enabled = CType(resources.GetObject("lblName.Enabled"), Boolean)
        Me.ErrorProvider1.SetError(Me.lblName, resources.GetString("lblName.Error"))
        Me.lblName.Font = CType(resources.GetObject("lblName.Font"), System.Drawing.Font)
        Me.ErrorProvider1.SetIconAlignment(Me.lblName, CType(resources.GetObject("lblName.IconAlignment"), System.Windows.Forms.ErrorIconAlignment))
        Me.ErrorProvider1.SetIconPadding(Me.lblName, CType(resources.GetObject("lblName.IconPadding"), Integer))
        Me.lblName.Image = CType(resources.GetObject("lblName.Image"), System.Drawing.Image)
        Me.lblName.ImageAlign = CType(resources.GetObject("lblName.ImageAlign"), System.Drawing.ContentAlignment)
        Me.lblName.ImageIndex = CType(resources.GetObject("lblName.ImageIndex"), Integer)
        Me.lblName.ImeMode = CType(resources.GetObject("lblName.ImeMode"), System.Windows.Forms.ImeMode)
        Me.lblName.Location = CType(resources.GetObject("lblName.Location"), System.Drawing.Point)
        Me.lblName.Name = "lblName"
        Me.lblName.RightToLeft = CType(resources.GetObject("lblName.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.lblName.Size = CType(resources.GetObject("lblName.Size"), System.Drawing.Size)
        Me.lblName.TabIndex = CType(resources.GetObject("lblName.TabIndex"), Integer)
        Me.lblName.Text = resources.GetString("lblName.Text")
        Me.lblName.TextAlign = CType(resources.GetObject("lblName.TextAlign"), System.Drawing.ContentAlignment)
        Me.lblName.Visible = CType(resources.GetObject("lblName.Visible"), Boolean)
        '
        'txtName
        '
        Me.txtName.AccessibleDescription = resources.GetString("txtName.AccessibleDescription")
        Me.txtName.AccessibleName = resources.GetString("txtName.AccessibleName")
        Me.txtName.Anchor = CType(resources.GetObject("txtName.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.txtName.AutoSize = CType(resources.GetObject("txtName.AutoSize"), Boolean)
        Me.txtName.BackgroundImage = CType(resources.GetObject("txtName.BackgroundImage"), System.Drawing.Image)
        Me.txtName.Dock = CType(resources.GetObject("txtName.Dock"), System.Windows.Forms.DockStyle)
        Me.txtName.Enabled = CType(resources.GetObject("txtName.Enabled"), Boolean)
        Me.ErrorProvider1.SetError(Me.txtName, resources.GetString("txtName.Error"))
        Me.txtName.Font = CType(resources.GetObject("txtName.Font"), System.Drawing.Font)
        Me.ErrorProvider1.SetIconAlignment(Me.txtName, CType(resources.GetObject("txtName.IconAlignment"), System.Windows.Forms.ErrorIconAlignment))
        Me.ErrorProvider1.SetIconPadding(Me.txtName, CType(resources.GetObject("txtName.IconPadding"), Integer))
        Me.txtName.ImeMode = CType(resources.GetObject("txtName.ImeMode"), System.Windows.Forms.ImeMode)
        Me.txtName.Location = CType(resources.GetObject("txtName.Location"), System.Drawing.Point)
        Me.txtName.MaxLength = CType(resources.GetObject("txtName.MaxLength"), Integer)
        Me.txtName.Multiline = CType(resources.GetObject("txtName.Multiline"), Boolean)
        Me.txtName.Name = "txtName"
        Me.txtName.PasswordChar = CType(resources.GetObject("txtName.PasswordChar"), Char)
        Me.txtName.RightToLeft = CType(resources.GetObject("txtName.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.txtName.ScrollBars = CType(resources.GetObject("txtName.ScrollBars"), System.Windows.Forms.ScrollBars)
        Me.txtName.Size = CType(resources.GetObject("txtName.Size"), System.Drawing.Size)
        Me.txtName.TabIndex = CType(resources.GetObject("txtName.TabIndex"), Integer)
        Me.txtName.Text = resources.GetString("txtName.Text")
        Me.txtName.TextAlign = CType(resources.GetObject("txtName.TextAlign"), System.Windows.Forms.HorizontalAlignment)
        Me.txtName.Visible = CType(resources.GetObject("txtName.Visible"), Boolean)
        Me.txtName.WordWrap = CType(resources.GetObject("txtName.WordWrap"), Boolean)
        '
        'nudSideMargin
        '
        Me.nudSideMargin.AccessibleDescription = resources.GetString("nudSideMargin.AccessibleDescription")
        Me.nudSideMargin.AccessibleName = resources.GetString("nudSideMargin.AccessibleName")
        Me.nudSideMargin.Anchor = CType(resources.GetObject("nudSideMargin.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.nudSideMargin.Dock = CType(resources.GetObject("nudSideMargin.Dock"), System.Windows.Forms.DockStyle)
        Me.nudSideMargin.Enabled = CType(resources.GetObject("nudSideMargin.Enabled"), Boolean)
        Me.ErrorProvider1.SetError(Me.nudSideMargin, resources.GetString("nudSideMargin.Error"))
        Me.nudSideMargin.Font = CType(resources.GetObject("nudSideMargin.Font"), System.Drawing.Font)
        Me.ErrorProvider1.SetIconAlignment(Me.nudSideMargin, CType(resources.GetObject("nudSideMargin.IconAlignment"), System.Windows.Forms.ErrorIconAlignment))
        Me.ErrorProvider1.SetIconPadding(Me.nudSideMargin, CType(resources.GetObject("nudSideMargin.IconPadding"), Integer))
        Me.nudSideMargin.ImeMode = CType(resources.GetObject("nudSideMargin.ImeMode"), System.Windows.Forms.ImeMode)
        Me.nudSideMargin.Location = CType(resources.GetObject("nudSideMargin.Location"), System.Drawing.Point)
        Me.nudSideMargin.Maximum = New Decimal(New Integer() {10000, 0, 0, 0})
        Me.nudSideMargin.Name = "nudSideMargin"
        Me.nudSideMargin.RightToLeft = CType(resources.GetObject("nudSideMargin.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.nudSideMargin.Size = CType(resources.GetObject("nudSideMargin.Size"), System.Drawing.Size)
        Me.nudSideMargin.TabIndex = CType(resources.GetObject("nudSideMargin.TabIndex"), Integer)
        Me.nudSideMargin.TextAlign = CType(resources.GetObject("nudSideMargin.TextAlign"), System.Windows.Forms.HorizontalAlignment)
        Me.nudSideMargin.ThousandsSeparator = CType(resources.GetObject("nudSideMargin.ThousandsSeparator"), Boolean)
        Me.nudSideMargin.UpDownAlign = CType(resources.GetObject("nudSideMargin.UpDownAlign"), System.Windows.Forms.LeftRightAlignment)
        Me.nudSideMargin.Visible = CType(resources.GetObject("nudSideMargin.Visible"), Boolean)
        '
        'lblSideMargin
        '
        Me.lblSideMargin.AccessibleDescription = resources.GetString("lblSideMargin.AccessibleDescription")
        Me.lblSideMargin.AccessibleName = resources.GetString("lblSideMargin.AccessibleName")
        Me.lblSideMargin.Anchor = CType(resources.GetObject("lblSideMargin.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.lblSideMargin.AutoSize = CType(resources.GetObject("lblSideMargin.AutoSize"), Boolean)
        Me.lblSideMargin.Dock = CType(resources.GetObject("lblSideMargin.Dock"), System.Windows.Forms.DockStyle)
        Me.lblSideMargin.Enabled = CType(resources.GetObject("lblSideMargin.Enabled"), Boolean)
        Me.ErrorProvider1.SetError(Me.lblSideMargin, resources.GetString("lblSideMargin.Error"))
        Me.lblSideMargin.Font = CType(resources.GetObject("lblSideMargin.Font"), System.Drawing.Font)
        Me.ErrorProvider1.SetIconAlignment(Me.lblSideMargin, CType(resources.GetObject("lblSideMargin.IconAlignment"), System.Windows.Forms.ErrorIconAlignment))
        Me.ErrorProvider1.SetIconPadding(Me.lblSideMargin, CType(resources.GetObject("lblSideMargin.IconPadding"), Integer))
        Me.lblSideMargin.Image = CType(resources.GetObject("lblSideMargin.Image"), System.Drawing.Image)
        Me.lblSideMargin.ImageAlign = CType(resources.GetObject("lblSideMargin.ImageAlign"), System.Drawing.ContentAlignment)
        Me.lblSideMargin.ImageIndex = CType(resources.GetObject("lblSideMargin.ImageIndex"), Integer)
        Me.lblSideMargin.ImeMode = CType(resources.GetObject("lblSideMargin.ImeMode"), System.Windows.Forms.ImeMode)
        Me.lblSideMargin.Location = CType(resources.GetObject("lblSideMargin.Location"), System.Drawing.Point)
        Me.lblSideMargin.Name = "lblSideMargin"
        Me.lblSideMargin.RightToLeft = CType(resources.GetObject("lblSideMargin.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.lblSideMargin.Size = CType(resources.GetObject("lblSideMargin.Size"), System.Drawing.Size)
        Me.lblSideMargin.TabIndex = CType(resources.GetObject("lblSideMargin.TabIndex"), Integer)
        Me.lblSideMargin.Text = resources.GetString("lblSideMargin.Text")
        Me.lblSideMargin.TextAlign = CType(resources.GetObject("lblSideMargin.TextAlign"), System.Drawing.ContentAlignment)
        Me.lblSideMargin.Visible = CType(resources.GetObject("lblSideMargin.Visible"), Boolean)
        '
        'chkVisible
        '
        Me.chkVisible.AccessibleDescription = resources.GetString("chkVisible.AccessibleDescription")
        Me.chkVisible.AccessibleName = resources.GetString("chkVisible.AccessibleName")
        Me.chkVisible.Anchor = CType(resources.GetObject("chkVisible.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.chkVisible.Appearance = CType(resources.GetObject("chkVisible.Appearance"), System.Windows.Forms.Appearance)
        Me.chkVisible.BackgroundImage = CType(resources.GetObject("chkVisible.BackgroundImage"), System.Drawing.Image)
        Me.chkVisible.CheckAlign = CType(resources.GetObject("chkVisible.CheckAlign"), System.Drawing.ContentAlignment)
        Me.chkVisible.Dock = CType(resources.GetObject("chkVisible.Dock"), System.Windows.Forms.DockStyle)
        Me.chkVisible.Enabled = CType(resources.GetObject("chkVisible.Enabled"), Boolean)
        Me.ErrorProvider1.SetError(Me.chkVisible, resources.GetString("chkVisible.Error"))
        Me.chkVisible.FlatStyle = CType(resources.GetObject("chkVisible.FlatStyle"), System.Windows.Forms.FlatStyle)
        Me.chkVisible.Font = CType(resources.GetObject("chkVisible.Font"), System.Drawing.Font)
        Me.ErrorProvider1.SetIconAlignment(Me.chkVisible, CType(resources.GetObject("chkVisible.IconAlignment"), System.Windows.Forms.ErrorIconAlignment))
        Me.ErrorProvider1.SetIconPadding(Me.chkVisible, CType(resources.GetObject("chkVisible.IconPadding"), Integer))
        Me.chkVisible.Image = CType(resources.GetObject("chkVisible.Image"), System.Drawing.Image)
        Me.chkVisible.ImageAlign = CType(resources.GetObject("chkVisible.ImageAlign"), System.Drawing.ContentAlignment)
        Me.chkVisible.ImageIndex = CType(resources.GetObject("chkVisible.ImageIndex"), Integer)
        Me.chkVisible.ImeMode = CType(resources.GetObject("chkVisible.ImeMode"), System.Windows.Forms.ImeMode)
        Me.chkVisible.Location = CType(resources.GetObject("chkVisible.Location"), System.Drawing.Point)
        Me.chkVisible.Name = "chkVisible"
        Me.chkVisible.RightToLeft = CType(resources.GetObject("chkVisible.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.chkVisible.Size = CType(resources.GetObject("chkVisible.Size"), System.Drawing.Size)
        Me.chkVisible.TabIndex = CType(resources.GetObject("chkVisible.TabIndex"), Integer)
        Me.chkVisible.Text = resources.GetString("chkVisible.Text")
        Me.chkVisible.TextAlign = CType(resources.GetObject("chkVisible.TextAlign"), System.Drawing.ContentAlignment)
        Me.chkVisible.Visible = CType(resources.GetObject("chkVisible.Visible"), Boolean)
        '
        'ErrorProvider1
        '
        Me.ErrorProvider1.ContainerControl = Me
        Me.ErrorProvider1.Icon = CType(resources.GetObject("ErrorProvider1.Icon"), System.Drawing.Icon)
        '
        'URelation
        '
        Me.AccessibleDescription = resources.GetString("$this.AccessibleDescription")
        Me.AccessibleName = resources.GetString("$this.AccessibleName")
        Me.AutoScroll = CType(resources.GetObject("$this.AutoScroll"), Boolean)
        Me.AutoScrollMargin = CType(resources.GetObject("$this.AutoScrollMargin"), System.Drawing.Size)
        Me.AutoScrollMinSize = CType(resources.GetObject("$this.AutoScrollMinSize"), System.Drawing.Size)
        Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
        Me.Controls.Add(Me.nudSideMargin)
        Me.Controls.Add(Me.lblSideMargin)
        Me.Controls.Add(Me.chkVisible)
        Me.Controls.Add(Me.lblName)
        Me.Controls.Add(Me.txtName)
        Me.Enabled = CType(resources.GetObject("$this.Enabled"), Boolean)
        Me.ErrorProvider1.SetError(Me, resources.GetString("$this.Error"))
        Me.Font = CType(resources.GetObject("$this.Font"), System.Drawing.Font)
        Me.ErrorProvider1.SetIconAlignment(Me, CType(resources.GetObject("$this.IconAlignment"), System.Windows.Forms.ErrorIconAlignment))
        Me.ErrorProvider1.SetIconPadding(Me, CType(resources.GetObject("$this.IconPadding"), Integer))
        Me.ImeMode = CType(resources.GetObject("$this.ImeMode"), System.Windows.Forms.ImeMode)
        Me.Location = CType(resources.GetObject("$this.Location"), System.Drawing.Point)
        Me.Name = "URelation"
        Me.RightToLeft = CType(resources.GetObject("$this.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.Size = CType(resources.GetObject("$this.Size"), System.Drawing.Size)
        CType(Me.nudSideMargin, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private mChanged As Boolean

    Public Event ValueChanged As EventHandler

    Private Sub URelation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler txtName.TextChanged, AddressOf OnValueChanged
        AddHandler nudSideMargin.ValueChanged, AddressOf OnValueChanged : AddHandler nudSideMargin.TextChanged, AddressOf OnValueChanged
        AddHandler chkVisible.CheckedChanged, AddressOf OnValueChanged
    End Sub
    Private Sub txtName_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.Validated
        If txtName.Text = "" Then
            ErrorProvider1.SetError(txtName, "Relation Name is required.")
        Else
            ErrorProvider1.SetError(txtName, "")
        End If
    End Sub

    Protected Sub OnValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RaiseEvent ValueChanged(Me, New EventArgs)
    End Sub

    Public Property Changed() As Boolean
        Get
            Return mChanged
        End Get
        Set(ByVal Value As Boolean)
            mChanged = Value
        End Set
    End Property

    Public Sub Read(ByVal relation As Model10.Relation)
        txtName.Text = relation.Name
        nudSideMargin.Value = relation.SideMargin
        chkVisible.Checked = relation.Visible
    End Sub
    Public Sub Write(ByVal relation As Model10.Relation)
        relation.Name = txtName.Text
        relation.SideMargin = CInt(nudSideMargin.Value)
        relation.Visible = chkVisible.Checked
    End Sub
End Class